<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>申请书编辑</title>
<script type="text/javascript" src="${res}/js/jquery/jquery.form.js"></script>
<script type="text/javascript"
	src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript"
	src="${res}/js/validate/irisvalidator.js"></script>
<script type="text/javascript"
	src="${res}/js/keyword/keywordtips.js"></script>	
<script type="text/javascript"
	src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>

<style>	
	textarea{overflow:auto;}
</style>
<script type="text/javascript">
$(function(){
	queryflex();
});
/**
 * 申请书提交方法
 */


var ctxpath = "${ctx}";
var prcWin = new progressWin("${res}");//初始化遮罩层
/**
 * 页面初始化方法 所有的都定义在里面
 */
$(document).ready (function() {
	$("#wbox1").click(function() {
		check("check");
	});
	
	$("#wbox2").click(function() {
		
		check("check");
		
	});
	
	initControl();
	
	$("table.t_css").not("[id='finances']").not("[id='checkbox_table_']").not("[id='budgetsMsg2']").each(function(){
		$(this).find("tr:even").addClass("li_1");
		$(this).find("tr:odd").addClass("li_2");
	});
	$("table").addClass("table01");
	$("#checkbox_table_").removeClass("table01");
	$("#feaReport_upload").removeClass("table01");
	$("#prpProduct_text").removeClass("table01");
	$("#gg_prpProduct_text").removeClass("table01");
	
	
    $('div').find("[id^='checkbox_dyn_']").find("tr").removeClass("li_1").removeClass("li_2");
    $('div').find("[id^='checkbox_dyn_']").find("td").css("border",'0px solid');
	
	window.setInterval("checkPdfStatus()", "10000");//检验申请书的pdf
});

$(document).ready(function() {
	fileInit("feaReport_upload","DOC,DOCX,PDF,WPS");
	fileInit("prpProduct_text","DOC,DOCX,PDF,WPS");
	fileInit("gg_prpProduct_text","DOC,DOCX,PDF,WPS");
/* 	fileInit("prpContent_upload","JPG,PDF,TIFF,XLS,DOC,WPS",null,"{'JPG':'51200','PDF':'51200','TIFF':'51200','XLS':'51200','DOC':'51200','WPS':'51200'}");	
 */ 
	fileInit("prpContent_upload","PDF,DOC,DOCX,WPS",null,"");	
 //fileInitAttach("attachAdd", "JPG,PDF", null, 20, "{'JPG':'3072','PDF':'3072'}");
	$("#prpContent_upload").find(".file").hide();//隐藏文本框
});


$(document).ready(function() {
	$("#org").attr("disabled","true");
	initDepartForComplete("org");
	 initControl();
	 $("#subject1").attr("disabled",false);
	 $("#subject2").attr("disabled",false);
});

/**
 * 申报日期默认为当前日期
 */
$(document).ready(function() {

	var nowDate = '${sercverSysDate1}';
    if($("#submit_date").val()==""){
	   $("#submit_date").val(nowDate);
    }

});

function ContentDownDesc(template) {
	window.open("${res_app}/template/content/"
			+ encodeURIComponent(template));

}

/**
 * 填写检查
 */
function check(type){
	
	validate($("#basicInfo"),"基本情况-->候选人基本情况");
	var subject1 = $("#subject1").val();
	var subject2 = $("#subject2").val();
	var subject3 = $("#subject3").val();
	if(subject1 == "" && subject2 =="" && subject3=="")
		irisValaddMsg("基本情况-->候选人基本情况-->学科分类名称及代码请至少选择一个");
	
	if(subject1 != "" && subject2 != ""){
		if(subject1 == subject2)
			irisValaddMsg("项目基本情况-->学科分类名称及代码1与学科分类名称及代码2重复");
	}
	if(subject1 != "" && subject3 != ""){
		if(subject1 == subject3)
			irisValaddMsg("项目基本情况-->学科分类名称及代码1与学科分类名称及代码3重复");
	}
	if(subject2 != "" && subject3 != ""){
		if(subject2 == subject3)
			irisValaddMsg("项目基本情况-->学科分类名称及代码2与学科分类名称及代码3重复");
	}
	validate($("#basicInfo2"),"基本情况-->候选人基本情况");
	
	var recommend_type = $("#recommend_type_value").val();
	if(recommend_type == '01'){
		validate($("#basicInfo3"),"基本情况-->候选人基本情况");
	}
	validate($("#basicInfo4"),"基本情况-->候选人基本情况");
	validateByTabRow($("#tblMileStones"),"工作简历-->工作简历",1);
	validate($("#feaReport_upload"),"成就和贡献"); 
	
	validate($("#paper_show"),"论文发表情况");
	validateByTabRow($("#tabPaper"),"论文发表情况-->主要论文专著目录",1);
	
	validate($("#third_comment"),"论文引用情况");
	validateByTabRow($("#tabRepresentPaper"),"论文引用情况-->主要论文专著被引用情况表",1);
	
	validateByTabRow($("#knowledge"),"知识产权证明-->主要知识产权证明目录",1);
	
	validateByTabRow($("#tblMainPsn"),"科技奖励-->候选人曾获科技奖励情况",1);
	
	if($("#recommend_type").val() == '02')
    	validate($("#gg_prpProduct_text"),"推荐专家意见"); 
	
	//prp_attach();
	
	validateByTabRow($("#award_fjmucl"),"附件材料目录-->附件材料目录");
	 var prp_attach_arrays_check=new Array();
   var boolean_contains=false;
   var total=0;
   var total1=0;
   $("#award_fjmucl > tbody").find("tr:gt(0)").each(function(){
 		var v=$(this).find("[name$='jcyjzdgxj_fjmu_value']").val();
 		if(v!=''){
 			for ( var i = 0; i < prp_attach_arrays_check.length; i++) {
				if(prp_attach_arrays_check[i]==v){
					boolean_contains=true;
					break;
				}
			}
 			if(!boolean_contains){
 				prp_attach_arrays_check.push(v);
 			}
 		}
 	});

   prp_attach_arrays_check.sort(); 
   for ( var i = 0; i < prp_attach_arrays_check.length; i++) {

		if(prp_attach_arrays_check[i]=='1123'){
		 	checkAttach(1123,0,'代表性论文专著证明','');
		}else if(prp_attach_arrays_check[i]=='1124'){
			checkAttach(1124,0,'代表性论文专著他引证明','');
		}else if(prp_attach_arrays_check[i]=='1125'){
			checkAttach(1125,0,'知识产权证明','');
		}else if(prp_attach_arrays_check[i]=='1126'){
			checkAttach(1126,0,'获奖证明','');
		}else if(prp_attach_arrays_check[i]=='1127'){
			checkAttach(1127,0,'其他证明','');
		}else if(prp_attach_arrays_check[i]=='1135'){
		 	checkAttach(1135,0,'代表性论文专著证明','');
		}else if(prp_attach_arrays_check[i]=='1136'){
			checkAttach(1136,0,'代表性论文专著他引证明','');
		}else if(prp_attach_arrays_check[i]=='1137'){
			checkAttach(1137,0,'知识产权证明','');
		}else if(prp_attach_arrays_check[i]=='1138'){
			checkAttach(1138,0,'获奖证明','');
		}else if(prp_attach_arrays_check[i]=='1139'){
			checkAttach(1139,0,'其他证明','');
		}
	}
    
	if(!valResult()){
		irisValShowMsg($("#wbox1"));
		return false;
	}
	if(type=="check"){
		showBox($("#wbox1"), "300px", "200px", "检查通过","1:所有检查全部合格");
	}
	return true;
}


function setTotalAmt(){
	/* $('#total_amt').val($("#input_total").val()); */
	$('#request_amt').val($("#source_apply").val());
}



</script>
<style>
	textarea{overflow:   auto;}
</style>
</head>
<body>

	<c:set var="xmlstr" value="${xmlData}" />
	<x:parse xml="${xmlstr}" var="xmlData" />
	
	<c:set var="nature_value">
	<x:out
		select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" />
	</c:set>
	<input type="hidden" id="nature_value1"  value="<x:out
		select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" />"/>
	

	
	<input type="hidden" id="childDiv" class="thickbox"/>
	<input type="hidden" id="filePath" value="${ctx}/file/ajax-filedownload?fileCode=" />
	<input type="hidden" id="menuId" value="${param.menuId}" />
	<input type="hidden" id="sysDate" value="${sercverSysDate}" />
	
	<div id="showMessage"></div>
	<div id="content">
		
		<cpt:helpTips key="prpedit" id="prpEditTips"></cpt:helpTips>
		<div class="clear_h15"></div>
		<div class="word_box" id="mainDiv">
			<div class="bar_btn">
				<span class="left"> 
					<c:set var="grantCode"><x:out select="$xmlData/data/proposal/grant_code" /></c:set>
					<c:set var="flag_shizhi"><x:out select="$xmlData/data/proposal/flag_shizhi" /></c:set>
					<input name="Submit" type="button" class="button_01" value="保存" onclick="saveAction()" /> 
					&nbsp; <c:if test="${not empty fbl.pdfViewUrl}"><input name="Submit" type="button" class="button_01" value="下载PDF"  onclick="genPdfAction()"/></c:if>
					<security:authorize ifNotGranted="A_DAILU_PROPOSAL">
					&nbsp; <input name="Submit" type="button" class="button_01"	value="提交给单位管理员" onclick="submitAction()" />
					</security:authorize>
					<security:authorize ifAnyGranted="A_DAILU_PROPOSAL">
					&nbsp; <input name="Submit" type="button" class="button_01"	value="提交到归口管理部门" onclick="submitAction()" />
					</security:authorize> 
					&nbsp; <input name="Submit" type="button" class="button_01" value="返回" onclick="backToList()" />
				</span>
				<span class="right"> 
					<input title="填写检查" class="btn_inspect" type="button" id="wbox1"/>
				</span>
				<span class="right">
				<c:set var="template">
					<c:if test="${grantCode ne 2513 }">安徽省科学技术最高成就奖填写说明.doc</c:if>
					<c:if test="${grantCode eq 2513 }">安徽省基础研究重大贡献奖填写说明.doc</c:if>
				</c:set>
				<input name="Submit" type="button" class="button_01" value="填写说明" onclick="return ContentDownDesc('${template}');" />&nbsp;&nbsp;
				</span>
					<c:set var="sub_grant_code"><x:out select="$xmlData/data/proposal/sub_grant_code" /></c:set>
					
			</div>
			<div class="bar_b">
				<input type="hidden" id="pdfStatus" value="${pdfStatus}" />
				<span class="right">版本号：<span name="proposal/prp_version" id="prp_version"><x:out select="$xmlData/data/proposal/prp_version" /></span></span>
			</div>
			<form method="post" id="mainForm">
				<input type="hidden" value="${grantCode}" id="grantCode"
					name="grantCode"> 
				<input type="hidden" value="${posCode}" id="posCode" name="posCode"> 
				<input type="hidden" value="<iris:des3 code="${posCode}"></iris:des3>" id="posCodeDes" name="posCodeDes">
				<input type="hidden" value="<iris:des3 code="${fbl.pdfCode}"></iris:des3>" id="pdfCodeDes" name="pdfCodeDes">  
				<input type="hidden" value="${xmlData}" id="xmlData" name="xmlData">
				<input type="hidden" value="${fbl.pdfCode}" id="pdfCode" name="pdfCode"> 
				<input type="hidden" value="${flag_shizhi}" id="flag_shizhi" name="proposal/flag_shizhi"> 
			</form>
				<div class="word_title">
					<c:set var="statYear">${statYear}</c:set>
					<c:if test="${empty statYear}">
						<c:set var="statYear"><x:out select="$xmlData/data/proposal/stat_year" /></c:set>
					</c:if>
					<span name="proposal/grant_name" ><x:out select="$xmlData/data/proposal/grant_name" /></span>-推荐书 (<span name="proposal/stat_year">${year}</span>年)<br />					
					<c:set var="grantCode"><x:out select="$xmlData/data/proposal/grant_code" /></c:set>
					<%-- (<x:out select="$xmlData/data/proposal/sub_grant_name" />) --%>
					
					<c:set  var="personname"><x:out select="$xmlData/data/zh_persons/zh_person[@submit_psn='1']/basic_info/zh_name" /></c:set>
								
					<input type="hidden" name="proposal/zh_title" value="${personname }-<x:out select="$xmlData/data/proposal/grant_name" />" />
					
					<input type="hidden" name="proposal/manage_category" value="<x:out select="$xmlData/data/proposal/manage_category" />" />
					<input type="hidden" name="proposal/sub_grant_name" value="<x:out select="$xmlData/data/proposal/sub_grant_name" />" />
					<input type="hidden" name="proposal/grant_code" value="<x:out select="$xmlData/data/proposal/grant_code" />" />  <input type="hidden" name="proposal/psn_code" value="<x:out select="$xmlData/data/proposal/psn_code" />" />
					<input type="hidden" id="grant_no" name="proposal/grant_no" value="<x:out select="$xmlData/data/proposal/grant_no" />" />							
					<input type="hidden" name="proposal/sub_grant_code" value="<x:out select="$xmlData/data/proposal/sub_grant_code" />" />
					<input name="proposal/register_area_code" type="hidden" value="<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/area_value" />" />
		            <input name="proposal/register_area_name" type="hidden" value="<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/area_name" />" />
					<input type="hidden" id="sub_grant_no" name="proposal/sub_grant_no" value="<x:out select="$xmlData/data/proposal/sub_grant_no" />" />
					<input type="hidden" name="proposal/help_grant_code" value="<x:out select="$xmlData/data/proposal/help_grant_code" />" />
					<input type="hidden" id="help_grant_no" name="proposal/help_grant_no" value="<x:out select="$xmlData/data/proposal/help_grant_no" />" />
					<c:set var="formCode"><x:out select="$xmlData/data/proposal/form_code" /></c:set>
					<c:set var="nature_value"><x:out select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" /> </c:set>
					<c:if test="${empty formCode}"><c:set var="formCode" value="${param.formCode}"></c:set></c:if>
					<input type="hidden" name="proposal/form_code" value="${formCode}" />
				    <input type="hidden" name="proposal/request_amt" 	id="request_amt" value="<x:out select="$xmlData/data/proposal/request_amt"/>">
					<input type="hidden" name="proposal/year" value="${year}" />
				 	<input type="hidden" name="proposal/org_type_name" id="org_type_name" value="" />
					<c:set var="org_type_name"><x:out select="$xmlData/data/proposal/org_type_name" /> </c:set>
				 <!-- 公用的配置界面 -->
				    <jsp:include page="./prpeditmain_public.jsp"><jsp:param value="${xmlstr}" name="xmlstr" /></jsp:include>
				</div>
				<div id="tabnav">
					<ul>
						<li class="down" id="tab1" onclick="changeTab(this.id)">
						    <a href="###"><span>基本情况</span></a>
						</li>
						<li  id="tab2" onclick="changeTab(this.id)">
						    <a href="###"><span>工作简历</span></a>
						</li>
						<li id="tab3" onclick="changeTab(this.id)" >
						    <a href="###"><span>成就和贡献</span></a>
						</li>
						<li id="tab5" onclick="changeTab(this.id)">
						    <a href="###"><span>论文发表情况</span></a>
						</li>
						<li id="tab4" onclick="changeTab(this.id)" >
						    <a href="###"><span>论文引用情况</span></a>
						</li>
						<li id="tab6" onclick="changeTab(this.id)" >
						    <a href="###"><span>知识产权证明</span></a>
						</li>
						<li id="tab8" onclick="changeTab(this.id)" >
						    <a href="###"><span>科技奖励</span></a>
						</li>	
						<li id="tab10" onclick="changeTab(this.id)" >
						    <a href="###"><span>推荐专家意见</span></a>
						</li>
						<li id="tab11" onclick="changeTab(this.id)" >
						    <a href="###"><span>附件材料目录</span></a>
						</li>
					</ul>
				</div>
				<div id="tabnav">
					<ul>
						<li id="tab9" onclick="changeTab(this.id)" >
						    <a href="###"><span>附件清单</span></a>
						</li>
					</ul>
				</div>
				
				<div class="tab_box" id="fragment-tab1">
					<jsp:include page="../info/prpInfoEdit_jcyjzdgxjtjs.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr" />
						<jsp:param value="${grantName}" name="grantName" />
						<jsp:param value="${statYear}" name="statYear" />
						<jsp:param value="${res_app}" name="res_app" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab2" style="display: none">
					<jsp:include page="../milestone/prpmilestoneedit_jcyjzdgxjtjs.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr" />
					</jsp:include>
				</div>
				
				<div class="tab_box" id="fragment-tab3" style="display: none">
					<jsp:include page="../content/prpContentEdit_jcyjzdgxjtjs.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab4" style="display: none">
					<jsp:include page="../content/prpContentEdit_jcyjzdgxjtjs1.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab5" style="display: none">
					<jsp:include page="../content/prpContentEdit_jcyjzdgxjtjs3.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab6" style="display: none">
					<jsp:include page="../milestone/prpmilestoneedit_jcyjzdgxjtjs1.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab8" style="display: none">
					<jsp:include page="../milestone/prpmilestoneedit_jcyjzdgxjtjs2.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab9" style="display: none">
					<jsp:include page="../attach/prpAttachEdit_by_common_cg.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab10" style="display: none">
					<jsp:include page="../content/prpContentEdit_jcyjzdgxjtjs2.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab11" style="display: none">
					<jsp:include page="../content/prpContentEdit_jcyjzdgxj_fjmucl.jsp">  
						<jsp:param value="${xmlstr}" name="xmlstr" />
						<jsp:param value="${grantCode}" name="grantCode" />
					</jsp:include>
				</div> 
			<div class="bar_btn02">
				<span class="left"> 
					<input name="Submit" type="button" class="button_01" value="保存" onclick="saveAction()" /> 
					&nbsp; <c:if test="${not empty fbl.pdfViewUrl}"><input name="Submit" type="button" class="button_01" value="下载PDF"  onclick="genPdfAction()"/></c:if>
					<security:authorize ifNotGranted="A_DAILU_PROPOSAL">
					&nbsp; <input name="Submit" type="button" class="button_01"	value="提交给单位管理员" onclick="submitAction()" />
					</security:authorize>
					<security:authorize ifAnyGranted="A_DAILU_PROPOSAL">
					&nbsp; <input name="Submit" type="button" class="button_01"	value="提交到归口管理部门" onclick="submitAction()" />
					</security:authorize> 
					&nbsp; <input name="Submit" type="button" class="button_01" value="返回" onclick="backToList()" /> 
				</span>
				<span class="right"> 
					<input title="填写检查" class="btn_inspect" type="button" id="wbox2"/>
				</span>
				<span class="right">
			    <input name="Submit" type="button" class="button_01" value="填写说明" onclick="return ContentDownDesc('${template}');" />&nbsp;&nbsp;
				</span>
			</div>
		</div>
		<div class="clear_h15"></div>
	</div>
</body>

</html>